import javax.swing.*;
import java.awt.*;

public class StartMenu extends JFrame {
    public StartMenu() {
        setTitle("井字棋 - 开始菜单");
        setSize(300, 200);
        setLocation(650, 350);
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        setLayout(new GridLayout(4, 1));

        JLabel label = new JLabel("请选择对战模式：", SwingConstants.CENTER);
        add(label);

        JButton aiBtn = new JButton("人机对战");
        aiBtn.addActionListener(e -> {
            dispose(); // 关闭当前窗口
            new GameGUI(GameMode.HUMAN_VS_AI);
        });

        JButton humanBtn = new JButton("双人对战");
        humanBtn.addActionListener(e -> {
            dispose(); // 关闭当前窗口
            new GameGUI(GameMode.HUMAN_VS_HUMAN);
        });

        JButton aiVsAiBtn = new JButton("机机互弈");
        aiVsAiBtn.addActionListener(e -> {
            dispose();
            new GameGUI(GameMode.AI_VS_AI);
        });


        add(aiBtn);
        add(humanBtn);
        add(aiVsAiBtn);

        setVisible(true);
    }
}
